package com.neu.elm.controller;

import com.neu.elm.po.Cart;
import com.neu.elm.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author:csw
 * @Date: 16:50 2020/9/15
 */
@RestController
@RequestMapping("/CartController")
public class CartController {

    @Autowired
    private CartService cartService;
    //http://localhost:8088/elm/cartController/listCart?userId=123&businessId=10001
    @RequestMapping("/listCart")
    public List<Cart> listCart(Cart cart)throws Exception{
        return cartService.listCart(cart);
    }

    //http://localhost:8088/elm/cartController/saveCart?quantity=1&foodId=2&businessId=10001&userId=123
    @RequestMapping("/saveCart")
    public int saveCart(Cart cart) throws Exception{
        return cartService.saveCart(cart);
    }

    //http://localhost:8088/elm/cartController/updateCart?quantity=2&foodId=2&businessId=10001&userId=123
    @RequestMapping("/updateCart")
    public int updateCart(Cart cart){
        return cartService.updateCart(cart);
    }

   // http://localhost:8088/elm/cartController/removeCart?userId=123&businessId=10002&foodId=1
    @RequestMapping("/removeCart")
    public int removeCart(Cart cart){
        return cartService.remoceCart(cart);
    }



}
